package com.test.auth_db_auto.support;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.test.auth_db_auto.mapper.UserMapper;
import com.test.auth_db_auto.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @ Author: .Mr
 * @ ClassName SmsUserDetailService
 * @ Description TODO
 * @ date 2022/1/5 13:59
 * @ Version 1.0
 */
@Service
public class SmsUserDetailService implements UserDetailsService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException {
        return userMapper.selectOne(Wrappers.<User>query().eq("mobile",mobile));
    }

    public int insertInfo(User user){
        return userMapper.insert(user);
    }

}
